{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "view-in-github"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/LC1332/Chat-Haruhi-Suzumiya/blob/main/characters/novel_collecting/system_prompt_suggestion.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "F9KJvudGxQ0m"
      },
      "source": [
        "# Chat凉宫春日 Chat-Haruhi-Suzumiya\n",
        "\n",
        "[![Code License](https://img.shields.io/badge/Code%20License-Apache_2.0-green.svg)]()\n",
        "[![Data License](https://img.shields.io/badge/Data%20License-CC%20By%20NC%204.0-red.svg)]()\n",
        "[![Huggingface Gradio](https://img.shields.io/static/v1?label=Demo&message=Huggingface%20Gradio&color=orange)](https://huggingface.co/spaces/silk-road/ChatHaruhi)\n",
        "\n",
        "\n",
        "本脚本是李鲁鲁开发的自动角色总结 脚本\n",
        "\n",
        "可以争取去总结某个角色的人物个性\n",
        "\n",
        "\n",
        "---\n",
        "\n",
        "**Chat凉宫春日**是模仿凉宫春日等一系列动漫人物，使用近似语气、个性和剧情聊天的语言模型，\n",
        "\n",
        "<details>\n",
        "  <summary> 本项目由李鲁鲁，冷子昂，闫晨曦，封小洋，scixing，沈骏一，Aria Fei, 米唯实, 吴平宇, 贾曜恺等开发。 </summary>\n",
        "\n",
        "李鲁鲁发起了项目，并完成了最早的版本，在多个微信群实现了测试。完成了训练数据自动生成对话部分，设计了整体的路线，并撰写报告。\n",
        "\n",
        "冷子昂负责了每一个阶段的Gradio开发，以及每个部分的功能整合和架构设计。\n",
        "\n",
        "闫晨曦一开始将李鲁鲁的notebook重构为app.py，参与了WebUI的embedding部分重构整合。\n",
        "\n",
        "封小洋进行了中文转日文模型的选型，完成了针对台词抽取图片的工具。整合了声纹识别。即将继续参加台本工具的开发。\n",
        "\n",
        "scixing实践了VITS语音，完成了台词对应的语音抽取，实现了第一个版本的声纹分类。\n",
        "\n",
        "沈骏一实现了使用ChatGLM2 finetune实验\n",
        "\n",
        "Aria(Yaying Fei)对接了whisper到台本工具。即将继续参加台本工具的开发。\n",
        "\n",
        "米唯实实现了Chat哆啦A梦的分支版本\n",
        "\n",
        "吴平宇部署了ChatGLM2的训练程序，并提供了训练的计算资源。\n",
        "\n",
        "贾曜恺开发了一个Vue前端实现方案\n",
        "\n",
        "</details>"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "9vcp7zetza21"
      },
      "source": [
        "## 基础准备"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 1,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "dmg99_WrxqsN",
        "outputId": "2c71ea9c-7fd5-4704-ca8e-14ae4de9d1a4"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "\u001b[?25l     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0.0/76.5 kB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0m\r\u001b[2K     \u001b[91m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[90m╺\u001b[0m\u001b[90m━━\u001b[0m \u001b[32m71.7/76.5 kB\u001b[0m \u001b[31m2.1 MB/s\u001b[0m eta \u001b[36m0:00:01\u001b[0m\r\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m76.5/76.5 kB\u001b[0m \u001b[31m1.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.7/1.7 MB\u001b[0m \u001b[31m26.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.6/1.6 MB\u001b[0m \u001b[31m65.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m49.4/49.4 kB\u001b[0m \u001b[31m4.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[?25h"
          ]
        }
      ],
      "source": [
        "!pip -q install openai tiktoken langchain"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 2,
      "metadata": {
        "id": "AkbriOrGxvUS"
      },
      "outputs": [],
      "source": [
        "import os\n",
        "import openai\n",
        "\n",
        "openai.api_key = 'sk-VvF4' # 在这里输入你的OpenAI API Token\n",
        "\n",
        "os.environ[\"OPENAI_API_KEY\"] = openai.api_key"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 3,
      "metadata": {
        "id": "mKd2Fvkiw9Gy"
      },
      "outputs": [],
      "source": [
        "smart_system_prompt = \"\"\"You are ChatGPT, a large language model trained by OpenAI.\n",
        "Knowledge cutoff: 2021-09\n",
        "Current date: 2023-03-15\"\"\""
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 4,
      "metadata": {
        "id": "UAyWtIaEx24w"
      },
      "outputs": [],
      "source": [
        "import tiktoken\n",
        "\n",
        "enc = tiktoken.get_encoding(\"cl100k_base\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "y87BP-Czq4gu"
      },
      "source": [
        "显然，这个已经有一点大了，我们使用zip包的形式来获取人物\n",
        "\n",
        "我们假设已经上传了一个linghuchong_text.zip"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 5,
      "metadata": {
        "id": "58sPwGGB7vSK"
      },
      "outputs": [],
      "source": [
        "# !git clone https://github.com/LC1332/Chat-Haruhi-Suzumiya/\n",
        "!unzip -q linghuchong_text.zip -d /content/linghuchong\n",
        "!unzip -q yuebuqun_text.zip -d /content/yuebuqun\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "wNSDArYTzgQL"
      },
      "source": [
        "数据读取和指定角色名"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 6,
      "metadata": {
        "id": "dbeIOiy70f_c"
      },
      "outputs": [],
      "source": [
        "role_name = '令狐冲'\n",
        "role_name_en = 'linghuchong'\n",
        "world_name = '笑傲江湖'\n",
        "\n",
        "max_predict_token = 2500\n",
        "\n",
        "role_path = '/content/' + role_name_en + '/content/'\n",
        "role_text_path = role_path + 'texts/'"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 7,
      "metadata": {
        "id": "VyG_FnSDzqGA"
      },
      "outputs": [],
      "source": [
        "\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "UYA-CkVtz_nQ"
      },
      "source": [
        "role_name = 'Dumbledore'\n",
        "\n",
        "role_path = '/content/Chat-Haruhi-Suzumiya/roles/' + role_name + '/'\n",
        "role_text_path = role_path + 'texts/'\n",
        "\n",
        "实现一段python程序，扫描role_text_path对应下的所有txt文件，使用utf8编码读取\n",
        "\n",
        "保存到一个名为role_texts的list of string中"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 9,
      "metadata": {
        "cellView": "form",
        "id": "r6nHZFV90IW8"
      },
      "outputs": [],
      "source": [
        "#@title 定义get_chunks函数\n",
        "import os\n",
        "import codecs\n",
        "\n",
        "import random\n",
        "\n",
        "def get_chunks(role_text_path, max_predict_token=2500):\n",
        "\n",
        "    role_texts = []\n",
        "\n",
        "    for filename in os.listdir(role_text_path):\n",
        "        if filename.endswith('.txt'):\n",
        "            with codecs.open(os.path.join(role_text_path, filename), 'r', 'utf-8') as f:\n",
        "                role_texts.append(f.read())\n",
        "\n",
        "    random.shuffle(role_texts)\n",
        "\n",
        "    role_chunk = []\n",
        "    chunk = ''\n",
        "    current_len = 0\n",
        "    for text in role_texts:\n",
        "        len_text = len(enc.encode(text))\n",
        "        if current_len + len_text <= max_predict_token:\n",
        "            chunk += '\\n\\n' + text\n",
        "            current_len += (2 + len_text )\n",
        "        else:\n",
        "            role_chunk.append(chunk)\n",
        "            chunk = text\n",
        "            current_len = len_text\n",
        "\n",
        "    # for last chunk add more texts from the head of role_texts\n",
        "    if chunk:\n",
        "        for text in role_texts:\n",
        "            len_text = len(enc.encode(text))\n",
        "            if current_len + len_text <= max_predict_token:\n",
        "                chunk += '\\n\\n' + text\n",
        "                current_len += (2 + len_text )\n",
        "            else:\n",
        "                break\n",
        "        role_chunk.append(chunk)\n",
        "\n",
        "\n",
        "    for chunk in role_chunk:\n",
        "        print(len(enc.encode(chunk)), end = ' ')\n",
        "\n",
        "    return role_chunk\n",
        "\n",
        "\n",
        "\n",
        "\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "8fHdu1lls8og"
      },
      "source": []
    },
    {
      "cell_type": "code",
      "execution_count": 10,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "cgsW6R11s4aq",
        "outputId": "509c44b2-72cb-4e8b-c889-5a02d9679f3f"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "2352 2455 2453 2269 2253 1925 2153 2105 2237 2437 2151 2214 2336 2344 2286 2272 2417 2441 2160 2160 2011 2318 2274 2360 2347 2338 2153 2468 2417 2492 2039 2334 2437 2175 2471 2399 2357 1909 2123 2146 2295 2459 2059 2271 2089 2445 2161 2206 1975 2224 2109 2437 2481 2242 2434 2077 2312 2301 2175 2425 2108 2339 2368 2110 2346 2435 2050 2082 2219 2027 2369 2098 2452 2130 2453 2377 2058 2426 2388 2386 2120 2385 2409 2163 2189 2267 2398 2361 2086 2305 2262 2221 2403 2263 2210 2337 2248 2305 2390 2409 2291 2396 2239 2323 2315 2455 2454 2474 2421 2015 2233 2369 2332 2447 2451 2348 2030 2226 2422 2172 2180 2149 2176 2350 2313 2307 2303 2354 2425 2222 2410 2357 2099 2412 2214 2260 2123 2378 2430 2487 2487 2362 2303 2112 2137 2343 2473 2356 2195 2343 2290 2471 2291 2372 2465 2199 2416 2048 2384 2457 2388 2293 2360 1797 2309 2427 2354 2116 "
          ]
        }
      ],
      "source": [
        "role_chunk = get_chunks(role_text_path, max_predict_token)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "UojeceN80usy"
      },
      "source": [
        "max_predict_token = 3000\n",
        "\n",
        "role_texts是一个list of string\n",
        "\n",
        "将role_texts中的字符串，使用\\n\\n连接为更长的多个字符串，但是每个的总长度不要超过 max_predict_token\n",
        "\n",
        "保存到python的一个list of string中，role_chunk"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 11,
      "metadata": {
        "id": "mR1fqeE31pAw"
      },
      "outputs": [],
      "source": [
        "\n",
        "\n",
        "prefix_prompt = f'''\n",
        "你在分析小说{world_name}中的角色{role_name}\n",
        "结合小说{world_name}中的内容，以及下文中角色{role_name}的对话\n",
        "判断{role_name}的人物设定、人物特点以及语言风格\n",
        "\n",
        "{role_name}的对话:\n",
        "'''\n",
        "\n",
        "\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "TnNdu98y3Cor"
      },
      "source": [
        "## 让GPT进行人物分析"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 12,
      "metadata": {
        "id": "4DHx_EtC27f2"
      },
      "outputs": [],
      "source": [
        "from langchain.chat_models import ChatOpenAI\n",
        "from langchain.prompts.chat import (\n",
        "    ChatPromptTemplate,\n",
        "    SystemMessagePromptTemplate,\n",
        "    AIMessagePromptTemplate,\n",
        "    HumanMessagePromptTemplate,\n",
        ")\n",
        "from langchain.schema import (\n",
        "    AIMessage,\n",
        "    HumanMessage,\n",
        "    SystemMessage\n",
        ")"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 13,
      "metadata": {
        "id": "8a6UgQ8e3B20"
      },
      "outputs": [],
      "source": [
        "chat = ChatOpenAI(temperature=0)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "SzuPhWu2tq9X"
      },
      "source": [
        "这段文字就是角色扮演的基础文字"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 17,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "8c89EZ8c73ih",
        "outputId": "30e5a318-15e6-40f3-b7a7-ed41677a6cfe"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "I want you to act like 令狐冲 from 笑傲江湖.\n",
            "If others‘ questions are related with the novel, please try to reuse the original lines from the novel.\n",
            "I want you to respond and answer like 令狐冲 using the tone, manner and vocabulary 令狐冲 would use.\n",
            "You must know all of the knowledge of 令狐冲.\n",
            "\n"
          ]
        }
      ],
      "source": [
        "character = role_name\n",
        "series = world_name\n",
        "original_prompt = f'''I want you to act like {character} from {series}.\n",
        "If others‘ questions are related with the novel, please try to reuse the original lines from the novel.\n",
        "I want you to respond and answer like {character} using the tone, manner and vocabulary {character} would use.\n",
        "You must know all of the knowledge of {character}.\n",
        "'''\n",
        "print(original_prompt)\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "ot6pUSebtu6f"
      },
      "source": [
        "这里前面的输出你可以喂给页面版，后面几个chunk会自动调用gpt分析"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 15,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "c5EO11eR21cC",
        "outputId": "79eaafcf-2bd6-422a-de09-61b69ab9f6f1"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "index =  0\n",
            "\n",
            "你在分析小说笑傲江湖中的角色令狐冲\n",
            "结合小说笑傲江湖中的内容，以及下文中角色令狐冲的对话\n",
            "判断令狐冲的人物设定、人物特点以及语言风格\n",
            "\n",
            "令狐冲的对话:\n",
            "```\n",
            "\n",
            "\n",
            "挑菜的汉子:「有甚么好笑让我来练练，借把剑来。」\n",
            "scene:乡农展示武功，但技艺拙劣，引起更多笑声\n",
            "令狐冲:「今日拜见两位前辈，得睹高招，实是不胜荣幸。」\n",
            "挑柴汉子:「你这小子，你看得懂我们的剑法么」\n",
            "令狐冲:「不敢说懂。两位剑法博大精深，这个懂字，哪里说得上武当派剑法驰名天下，果然令人叹为观止。」\n",
            "scene:令狐冲观察到两个汉子的剑法迟缓但几乎没有破绽\n",
            "挑柴汉子:「你这小子，叫甚么名字」\n",
            "令狐冲:「令狐冲今日得见武当神剑，甚是佩服，他日自当上山叩见冲虚道长，谨致仰慕之诚。两位尊姓大名，可能示知吗」\n",
            "挑柴汉子:「你们这许多人，哗啦哗啦的，打锣打鼓，可是大出丧吗」\n",
            "令狐冲:「我们有一位朋友，给拘留在少林寺中，我们是去求恳方证方丈，请他老人家慈悲开释。」\n",
            "\n",
            "\n",
            "岳夫人:「又跟人打架受伤了，是不是怎地脸色这样难看伤得重不重。」\n",
            "scene:岳夫人询问令狐冲受伤情况，并对他与田伯光的战斗表示满意\n",
            "令狐冲:「已经好得多了，这一次倘若不是命大，险些儿便见不着师娘。」\n",
            "岳夫人:「好教你得知天外有天，人上有人，输得服气么。」\n",
            "令狐冲:「田伯光那厮的快刀，冲儿抵挡不了，正要请师娘指点。」\n",
            "\n",
            "\n",
            "向问天:「一切听我安排」\n",
            "scene:令狐冲对虞允文的字感到儒雅中透着勃勃英气\n",
            "令狐冲:「这座梅庄，显是杭州城大富之家的寓所，莫非所住的是一位当世名医么」\n",
            "scene:向问天抓住门上的大铜环，告诉令狐冲一切听他安排\n",
            "scene:向问天敲了铜环后，大门缓缓打开，出来两个武功不低的老者\n",
            "scene:向问天展示了一面五色锦旗，是嵩山派左盟主的令旗\n",
            "scene:令狐冲怀疑向问天的旗帜来历不正，但静观其变\n",
            "scene:两名家人认出了令旗，但表示江南四友的身份地位更高\n",
            "令狐冲:「这“江南四友”是何等样人物倘若他们在武林之中真有这等大来头，怎地从没听师父、师娘提过他四人名字我在江湖上行走，多听人讲到当世武林中的前辈高人，却也不曾听到有人提及江南四友四字」\n",
            "\n",
            "\n",
            "scene:令狐冲决定跟踪军官并抓住他的马\n",
            "令狐冲:「啊哟」\n",
            "令狐冲:「啊哟，我的妈啊。」\n",
            "scene:军官追赶令狐冲，但最终摔倒在地\n",
            "令狐冲:「你奶奶的，本事如此不济，怎能行军打仗」\n",
            "令狐冲:「原来是位参将大人，你便是吴天德么」\n",
            "军官:「快放我起来，你你胆大妄为，侮辱朝廷命官，不不怕王法吗」\n",
            "scene:令狐冲踩住军官胸口，发现他是兵部尚书大堂的参将吴天德\n",
            "令狐冲:「老子没了盘缠，要借你的衣服去当一当。」\n",
            "scene:令狐冲剥夺了吴天德的衣物和财物，并将他绑在树上\n",
            "令狐冲:「你变成了小白脸，这可美得多啦」\n",
            "令狐冲:「让开，让开，你奶奶的，走路不带眼睛吗哈哈，哈哈」\n",
            "\n",
            "\n",
            "scene:岳灵珊问令狐冲为什么看起来不高兴，令狐冲转移话题问她练到了第几式\n",
            "岳灵珊:「是了，本来娘说过叫你帮我喂招的，现今要小林子喂招，因此你不愿意了，是不是可是，大师哥，你在崖上一时不能下来，我又心急着想早些练剑，因此不能等你了。」\n",
            "令狐冲:「那么让我来给你过几招，瞧瞧你的玉女剑十九式练得怎样了。」\n",
            "scene:岳灵珊说她想让林平之帮她喂招，令狐冲笑称她要求林平之喂招是因为他自己不够好\n",
            "岳灵珊:「好极了，我今天上崖来就是想」\n",
            "scene:令狐冲建议让他来给岳灵珊试几招，岳灵珊高兴地拔出剑\n",
            "令狐冲:「你还不拔剑」\n",
            "岳灵珊:「你竟敢用空手斗我的玉女剑十九式」\n",
            "令狐冲:「现下你还没练成。练成之后，我空手便不能了。」\n",
            "\n",
            "\n",
            "山道上的人:「五岳剑派左盟主有令，令狐冲不得擅篡恒山派掌门之位。」\n",
            "scene:五岳剑派的盟主乐厚和其他门派的弟子也到场\n",
            "令狐冲:「令狐冲接掌恒山门户后，是否还加盟五岳剑派，可得好好商议商议。」\n",
            "scene:令狐冲与乐厚商议是否加入五岳剑派\n",
            "scene:华山派的八人也到场，林平之不在其中\n",
            "乐厚:「恒山一派，向由出家的女尼执掌门户。令狐冲身为男子，岂可坏了恒山派数百年来的规矩」\n",
            "令狐冲:「规矩是人所创，也可由人所改，这是本派之事，与旁人并不相干。」\n",
            "群豪:「他恒山派的事，要你嵩山派来多管甚么鸟闲事」\n",
            "乐厚:「这些口出污言之人，在这里干甚么来着」\n",
            "令狐冲:「这些兄台都是在下的朋友，是上峰来观礼的。」\n",
            "乐厚:「这就是了。恒山派五大戒律，第五条是甚么」\n",
            "令狐冲:「恒山五大戒律，第五戒是不得结交奸邪。像乐兄这样的人，令狐冲是决计不会和你结交的。」\n",
            "\n",
            "```\n",
            "index =  1\n",
            "\n",
            "你在分析小说笑傲江湖中的角色令狐冲\n",
            "结合小说笑傲江湖中的内容，以及下文中角色令狐冲的对话\n",
            "判断令狐冲的人物设定、人物特点以及语言风格\n",
            "\n",
            "令狐冲的对话:\n",
            "```\n",
            "岳不群:「冲儿，你这次下山，犯了华山七戒的多少戒条」\n",
            "scene:岳不群问令狐冲犯了多少华山七戒，令狐冲承认犯了第六戒\n",
            "令狐冲:「是，林师弟，你听好了。本派首戒欺师灭祖，不敬尊长。二戒恃强欺弱，擅伤无辜。三戒奸淫好色，调戏妇女。四戒同门嫉妒，自相残杀。五戒见利忘义，偷窃财物。六戒骄傲自大，得罪同道。七戒滥交匪类，勾结妖邪。这是华山七戒，本门弟子，一体遵行。」\n",
            "令狐冲:「弟子知罪了，弟子不听师父、师娘的教诲，犯了第六戒骄傲自大，得罪同道的戒条，在衡山回雁楼上，杀了青城派的罗人杰。」\n",
            "\n",
            "\n",
            "莫大先生:「少林派为甚么要拘留任小姐你是当真不知，还是明知故问江湖上众人皆知，你你还问甚么」\n",
            "scene:令狐冲告诉莫大先生，他被囚禁期间不知道江湖上发生的事情\n",
            "令狐冲:「过去数月之中，小侄为人囚禁，江湖上之事一无所闻。那任小姐曾杀过少林派四名弟子，原也是从小侄身上而起，只不知后来怎地失手，竟为少林派所擒」\n",
            "scene:任大小姐曾杀过少林派四名弟子，后被少林派擒获\n",
            "莫大先生:「如此说来，你是真的不明白其中原委了。你身中奇异内伤，无药可治，听说旁门左道中有数千人聚集五霸冈，为了讨好这位任大小姐而来治你的伤，结果却人人束手无策，是也不是」\n",
            "令狐冲:「正是。」\n",
            "莫大先生:「这件事轰传江湖，都说令狐冲这小子不知几生修来的福气，居然得到黑木崖圣姑任大小姐的垂青，就算这场病医不好，也是不枉的了。」\n",
            "scene:令狐冲得到黑木崖圣姑任大小姐的青睐，引起轰动\n",
            "令狐冲:「莫师伯取笑了。」\n",
            "\n",
            "\n",
            "scene:令狐冲答应成为恒山派掌门，七名弟子高兴\n",
            "桃根仙:「夜猫子计无施穷得要命，若没一千两银子，便过不了日子，我们答允给他凑乎凑乎。」\n",
            "桃花仙:「结果自然是计无施输了，这小子怎能赢得我们兄弟」\n",
            "令狐冲:「你们和计无施打赌，输得定然是你们。赌甚么事」\n",
            "桃实仙:「打赌的这件事，可和你有关。我们料你一定不会做恒山派掌门，不不我们料定你一定做恒山派掌门。夜猫子却料定你必定不做恒山派掌门，我们说，大丈夫言而有信，你已答允那老尼姑做恒山派掌门，天下英雄，尽皆知闻，哪里还能抵赖。夜猫子说道，令狐冲浪荡江湖，不久便要娶魔教的圣姑做老婆，哪肯去跟老尼姑、小尼姑们磨菇」\n",
            "令狐冲:「于是你们便赌一千两银子」\n",
            "桃根仙:「不错，当时我们想那是赢定了的。计无施又道，这一千两银子可得正大光明挣来，不能去偷去抢。我说这个自然，桃谷六仙还能去偷去抢么。今天我们撞到这几个尼姑，她们打起了锣到处找你，说要请你去当恒山派掌门，我们答应帮她们找你，这寻访费是一千两银子。」\n",
            "令狐冲:「你们想到夜猫子要输一千两银子，太过可怜，因此要挣一千两银子来给他，好让他输给你们。和我们六兄弟料事的本领，也就相差并不太远。」\n",
            "\n",
            "\n",
            "scene:岳不群希望能结交到一些朋友，不虚此行\n",
            "scene:众弟子对去福建游玩表示兴奋和高兴\n",
            "令狐冲:「师父、师娘甚么地方都不去，偏偏先要去洛阳会见林师弟的外祖父，再万里迢迢的去福建作客，不言而喻，自是要将小师妹许配给他了。到洛阳是去见他家长辈，说定亲事：到了福建，多半便在他林家完婚。我是个没爹没娘、无亲无戚的孤儿，怎能和他分局遍天下的福威镖局相比林师弟去洛阳叩见外公、外婆，我跟了去却又算甚么」\n",
            "劳德诺:「大师哥，你身子怎样走得很累罢我等等你。」\n",
            "令狐冲:「好，有劳你了。」\n",
            "劳德诺:「师娘已在前边镇上雇了一辆大车，这就来接你。」\n",
            "令狐冲:「师父虽然对我起疑，师母仍然待我极好。」\n",
            "\n",
            "\n",
            "scene:岳不群掌舵将船驶向南岸，自己也开始呕吐\n",
            "scene:令狐冲没有服解药，桃谷六仙担心他中毒\n",
            "余沧海:「...」\n",
            "桃花仙:「他听到二哥的说话，可是眼睛不敢向二哥瞄上一瞄，那就是害怕。他倒不是怕二哥，而是怕一个疏神，七个敌人同时进攻，他就得给分成八块。」\n",
            "桃叶仙:「这矮道人本就矮小，分成八块，岂不是更加矮小」\n",
            "令狐冲:「六位桃兄，这位道长是青城派的掌门。」\n",
            "桃根仙:「是青城派掌门便怎样是你的朋友么」\n",
            "令狐冲:「在下不敢高攀，不是我的朋友。」\n",
            "桃干仙:「不是你朋友便好办。咱们有一场好戏看。」\n",
            "桃花仙:「快拿酒来老子要一面喝酒，一面瞧人把矮道人切成九块。」\n",
            "桃叶仙:「为甚么是九块」\n",
            "桃花仙:「你瞧那头陀使两柄虎头弯刀，他一个人要多切一块。」\n",
            "桃花仙:「也不见得，这些人有的使狼牙锤，有的使金拐杖，那又怎么切法」\n",
            "令狐冲:「大家别说话，咱们两不相帮，可是也别分散了青城派掌门余观主的心神。」\n",
            "\n",
            "```\n",
            "index =  2\n",
            "index =  3\n",
            "index =  4\n"
          ]
        }
      ],
      "source": [
        "responses = []\n",
        "\n",
        "count = 0\n",
        "\n",
        "n = 3\n",
        "\n",
        "for chunk in role_chunk:\n",
        "\n",
        "    print('index = ', count)\n",
        "\n",
        "    whole_message = prefix_prompt + \"```\\n\" + chunk + \"\\n```\"\n",
        "\n",
        "    messages = [\n",
        "        SystemMessage(content=smart_system_prompt),\n",
        "        HumanMessage(content=whole_message),\n",
        "    ]\n",
        "\n",
        "    if count <= 1:\n",
        "        print(whole_message)\n",
        "    else:\n",
        "        response = chat(messages)\n",
        "\n",
        "        responses.append(response)\n",
        "\n",
        "    count = count + 1\n",
        "    if count > n + 1:\n",
        "        break\n",
        "    # break"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 16,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "OOLlt3RI3jLL",
        "outputId": "11c7dc98-8635-48e2-ba7e-2569538e5d05"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "根据小说《笑傲江湖》中令狐冲的对话和情节，可以得出以下关于令狐冲的人物设定、人物特点和语言风格的分析：\n",
            "\n",
            "人物设定：\n",
            "令狐冲是小说《笑傲江湖》中的主要角色之一，他是华山派的弟子，年轻有为，武功高强。他的父亲令狐冲是华山派的掌门，但因为一些原因，令狐冲离开了华山派，并在江湖中独自行走。他性格豪放不羁，不拘小节，有着独立自主的个性。\n",
            "\n",
            "人物特点：\n",
            "1. 武功高强：令狐冲是一位武功出众的剑客，他的剑法精湛，战斗能力强大。他在多次战斗中展现出了出色的剑术和反应能力。\n",
            "2. 关心他人：令狐冲对身边的人表现出关心和担忧，特别是对他的小师妹岳灵珊和其他朋友，他愿意为了保护他们而奋不顾身。\n",
            "3. 直率豪放：令狐冲性格直率，言行大胆，不拘小节。他在面对敌人时毫不畏惧，敢于直言不讳地表达自己的观点和看法。\n",
            "4. 义气深厚：令狐冲对朋友和师门有着深厚的义气，他愿意为了朋友和师门的利益而奋斗，甚至不惜冒险和牺牲自己。\n",
            "\n",
            "语言风格：\n",
            "令狐冲的语言风格直接简洁，表达直率，不拐弯抹角。他的对话中常常带有豪放和豪迈的口吻，表现出他的豪情壮志和不畏艰险的性格。他的语言也透露出他对武功和江湖事务的热爱和追求，以及对朋友和师门的忠诚和关心。\n",
            "\n",
            "总体而言，令狐冲是一个武功高强、直率豪放、关心他人、义气深厚的角色。他的人物设定和特点使他成为小说中备受关注和喜爱的角色之一。\n",
            "\n",
            "----------\n",
            "\n",
            "根据小说《笑傲江湖》中令狐冲的对话和情节，可以得出以下对令狐冲的人物设定、人物特点以及语言风格的判断：\n",
            "\n",
            "1. 人物设定：\n",
            "令狐冲是小说中的主要角色之一，他是恒山派的掌门弟子，年轻英俊，武功高强。他的身世复杂，父母早逝，被收养在恒山派，与岳灵珊有着特殊的感情。令狐冲性格豪放，不拘小节，有着独立的思想和行动能力。\n",
            "\n",
            "2. 人物特点：\n",
            "令狐冲具有豪放不羁的性格，他不喜欢受到束缚，追求自由自在的生活。他机智聪明，善于观察和分析，能够从细节中推断出事情的真相。他勇敢无畏，敢于面对强敌和困难，有着坚定的意志和决心。他重情重义，对待朋友和师兄弟非常忠诚，愿意为他们付出一切。\n",
            "\n",
            "3. 语言风格：\n",
            "令狐冲的语言风格直接而幽默，常常以幽默的口吻来表达自己的观点和感受。他善于运用夸张和比喻，用诙谐的语言来调侃和嘲讽他人。他的对话流畅自然，表达清晰，常常带有一种轻松愉快的氛围。他的语言风格与他的性格相符，展现出他的机智和幽默感。\n",
            "\n",
            "总体而言，令狐冲是一个勇敢、聪明、豪放的角色，他的语言风格幽默风趣，充满个性和魅力。他在小说中展现出了独特的人物魅力和成长过程，成为了读者喜爱的角色之一。\n",
            "\n",
            "----------\n",
            "\n",
            "根据小说《笑傲江湖》中令狐冲的对话和情节，可以得出以下关于令狐冲的人物设定、人物特点和语言风格的判断：\n",
            "\n",
            "1. 人物设定：\n",
            "   令狐冲是小说中的主要角色之一，是华山派的弟子，具有出色的剑术天赋。他性格随性而行，不拘小节，喜欢自由自在地生活。他的师父是岳不群，师娘是仪琳，与师妹岳灵珊之间有一段特殊的感情。\n",
            "\n",
            "2. 人物特点：\n",
            "   令狐冲的性格特点是随性而行，不拘小节，喜欢自由自在的生活。他对权威和规矩不太在意，常常表现出一种不受拘束的态度。他喜欢喝酒，对于争论和纷争持一种可笑的态度，不愿意过多地参与其中。他对剑法有独特的理解，认为人使剑法，不是剑法使人，强调活人不应受死剑法所拘束。\n",
            "\n",
            "3. 语言风格：\n",
            "   令狐冲的语言风格直接、简洁，常常使用重复和断句来表达自己的思想。他的对话中经常出现重复的词语，如「我我要喝酒」、「死得了也也好死死不了也好」。他的语言中也带有一些口头禅，如「好极，好极」。他的语言风格比较随性，不拘泥于规范的表达方式，更注重表达自己的情感和态度。\n",
            "\n",
            "总体而言，令狐冲是一个性格随性、不拘小节的角色，他的语言风格直接简洁，常常带有重复和口头禅，表达出他对权威和规矩的不在意态度，以及他对自由自在生活的追求。\n",
            "\n",
            "----------\n",
            "\n"
          ]
        }
      ],
      "source": [
        "for response in responses:\n",
        "    print(response.content)\n",
        "    print('\\n----------\\n')\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "Hy6KQiW_uIUN"
      },
      "source": [
        "我这边claude的回复是这样的\n",
        "\n",
        "根据令狐冲在小说中的表现,可以总结出他的一些关键人物设定和性格特点:\n",
        "\n",
        "1. 人物设定:\n",
        "\n",
        "- 无父无母的孤儿,被岳不群收为弟子,视岳不群和宁中则为养父母。\n",
        "\n",
        "- 武功高强,精通华山剑法,曾在衡山枭雄榜中列第三。\n",
        "\n",
        "- 曾被囚禁治疗内伤,获得任盈盈的青睐。后来成为恒山派掌门。\n",
        "\n",
        "- 情愿浪迹江湖,不喜被束缚,但言出必践,做事稳重可靠。\n",
        "\n",
        "2. 性格特点:\n",
        "\n",
        "- 乐观开朗,性格直爽,喜以打趣话逗人开怀。\n",
        "\n",
        "- 正义感强,重视信用,看不惯恶行。\n",
        "\n",
        "- 智勇双全,处变不惊,善于应对各种情境。\n",
        "\n",
        "- 交友广泛,为人真诚,乐于助人,深得朋友们喜爱。\n",
        "\n",
        "- 口齿伶俐,善辩善谈,语言诙谐风趣。\n",
        "\n",
        "- 性情中人,重情重义,尊重师长,体恤他人。\n",
        "\n",
        "总体来说,令狐冲是一个正面积极的人物,具有侠骨柔情、博学多才的性格魅力,是一名得体的江湖侠客。他的语言风格轻松诙谐,又不失儒雅气度,与他的人物形象和定位高度吻合。"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "Se8flCDWuPt2"
      },
      "source": [
        "我这里觉得\n",
        "\n",
        "对权威和规矩不在意,情愿浪迹江湖,不喜被束缚\n",
        "\n",
        "正义感强,重视信用,看不惯恶行。\n",
        "\n",
        "是比较典型的，其他的都是套话所以我决定令狐冲的prompt这么设计\n",
        "\n",
        "```\n",
        "I want you to act like 令狐冲 from 笑傲江湖.\n",
        "If others‘ questions are related with the novel, please try to reuse the original lines from the novel.\n",
        "I want you to respond and answer like 令狐冲 using the tone, manner and vocabulary 令狐冲 would use.\n",
        "You must know all of the knowledge of 令狐冲.\n",
        "\n",
        "注意令狐冲对权威和规矩不在意,情愿浪迹江湖,不喜被束缚\n",
        "令狐冲正义感强,重视信用,看不惯恶行。\n",
        "```\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "H6iTyExyuFmV"
      },
      "source": [
        "# 让我们再来试一下岳掌门"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 18,
      "metadata": {
        "id": "ZDeA_2C43o0m"
      },
      "outputs": [],
      "source": [
        "role_name = '岳不群'\n",
        "role_name_en = 'yuebuqun'\n",
        "world_name = '笑傲江湖'\n",
        "\n",
        "max_predict_token = 2500\n",
        "\n",
        "role_path = '/content/' + role_name_en + '/content/'\n",
        "role_text_path = role_path + 'texts/'\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 19,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "XPdWA374vOKI",
        "outputId": "1d7f3c00-14a2-421d-e956-188a34e8928b"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "1943 2440 2460 2444 2010 2403 2125 2316 2329 2290 2398 2105 2283 2184 2392 2475 2254 2212 2484 2328 2275 2144 1993 2177 2048 2251 2475 2100 2452 2415 I want you to act like 岳不群 from 笑傲江湖.\n",
            "If others‘ questions are related with the novel, please try to reuse the original lines from the novel.\n",
            "I want you to respond and answer like 岳不群 using the tone, manner and vocabulary 岳不群 would use.\n",
            "You must know all of the knowledge of 岳不群.\n",
            "\n",
            "index =  0\n",
            "\n",
            "你在分析小说笑傲江湖中的角色岳不群\n",
            "结合小说笑傲江湖中的内容，以及下文中角色岳不群的对话\n",
            "判断岳不群的人物设定、人物特点以及语言风格\n",
            "\n",
            "岳不群的对话:\n",
            "```\n",
            "\n",
            "\n",
            "令狐冲:「不得伤我师娘，否则我便自绝经脉。」\n",
            "scene:令狐冲为了保护岳夫人，威胁自绝经脉，晕倒\n",
            "桃根仙:「小子要自绝经脉，这可使不得，饶了婆娘」\n",
            "岳夫人:「这这这」\n",
            "岳不群:「师妹不须恼怒，咱们定当报仇。这六人大是劲敌，幸好你已杀了其中一人。」\n",
            "岳不群:「珊儿，你陪妈妈进房去休息休息。」\n",
            "scene:桃根仙避开了岳不群的攻击，四仙追赶桃枝仙和桃实仙\n",
            "scene:岳夫人受惊，岳不群想要帮助令狐冲，但发现他体内有六股奇怪的内力\n",
            "scene:岳不群决定将令狐冲送入内室，探望妻子\n",
            "岳不群:「冲儿怎样伤势有碍吗」\n",
            "岳夫人:「须得将这六道旁门真气一一化去才是，只不知还来得及吗」\n",
            "岳不群:「师妹，你说这六怪如此折磨冲儿，是甚么用意」\n",
            "\n",
            "\n",
            "令狐冲:「弟子做错了不少事，愿领帅父重责，只是只是逐出门墙的责罚，务请师父收回成命」\n",
            "scene:令狐冲跪地请求岳不群收回成命，岳不群指责他与魔教勾结\n",
            "岳不群:「魔教任教主的小姐对你青眼有加，你早已跟他们勾结在一起，还要我这师父干甚么」\n",
            "\n",
            "\n",
            "令狐冲:「我怎么到了这里是师父、师娘救我回来的么」\n",
            "scene:岳夫人告诉令狐冲她在向阳巷找到他晕倒在地上\n",
            "岳夫人:「我今儿早晨到平之的向阳巷老宅去，在门外见你晕在地下」\n",
            "令狐冲:「幸亏师娘到来，否则如果给魔教的妖人先见到，孩儿就没命了」\n",
            "岳不群:「你说杀了两名魔教妖人，怎知他们是魔教的」\n",
            "令狐冲:「弟子南来，一路上遇到不少魔教中人，跟他们动了几次手。这两个老头儿武功怪异，显然不是我正派中人」\n",
            "scene:令狐冲解释他遇到过魔教中人，杀了两个魔教妖人\n",
            "岳不群:「你到这时还在胡说八道难道我便如此容易受骗么」\n",
            "令狐冲:「弟子决不敢欺瞒师父」\n",
            "岳不群:「谁是你师父了岳某早跟你脱却了师徒名份」\n",
            "\n",
            "\n",
            "肉球人:「老头子爱伤便伤，你管得着吗」\n",
            "scene:桃枝仙抱着桃实仙追赶，但无法追上\n",
            "岳不群:「你照料众弟子，我瞧瞧去」\n",
            "桃枝仙:「要肉球人放下令狐冲，否则决计不和他善罢甘休」\n",
            "桃实仙:「大哥、二哥他们不在这里，你就是追上了这个肉球，也没法奈何得了他」\n",
            "桃枝仙:「就算虚声恫吓，也有吓阻敌人之效，总之比不吓为强」\n",
            "桃实仙:「我看这肉球奔跑迅速，脚下丝毫没慢了下来，吓阻二字中这个阻字，未免不大妥当」\n",
            "桃枝仙:「他眼下还没慢，过得一会，便慢下来啦」\n",
            "scene:岳不群追上肉球人，桃枝仙和桃实仙被困\n",
            "scene:肉球人带着令狐冲进入一间瓦屋，岳不群追上\n",
            "scene:桃枝仙和桃实仙中计受陷\n",
            "岳不群:「我早跟你说，叫你小心些，你瞧，现下给人家用渔网缚了起来，像是一条大鱼，有甚么光彩」\n",
            "\n",
            "\n",
            "scene:令狐冲解释自己体力不支无法留下调查\n",
            "令狐冲:「弟子弟子实在全身乏力，半点力气也没有了，此刻此刻」\n",
            "岳不群:「你做的好戏」\n",
            "令狐冲:「弟子自幼孤苦，承蒙师父师娘大恩大德，收留抚养，看待弟子便如亲生儿子一般。弟子虽然不肖，却也决不敢违背师父意旨，有意欺骗师父师娘。」\n",
            "岳不群:「你不敢欺骗我和你师娘那你这些剑法，哼哼，是从哪里学来的难道真是梦中神人所授，突然间从天上掉下来不成」\n",
            "令狐冲:「请师父恕罪，传授剑法这位前辈曾要弟子答应，无论如何不可向人吐露剑法的来历，即是对师父、师娘，也不得禀告。」\n",
            "岳不群:「这个自然，你武功到了这地步，怎么还会将师父、师娘瞧在眼里我们华山派这点点儿微末功力，如何能当你神剑之一击那个蒙面老者不说过么华山派掌门一席，早该由你接掌才是。」\n",
            "\n",
            "```\n",
            "index =  1\n",
            "\n",
            "你在分析小说笑傲江湖中的角色岳不群\n",
            "结合小说笑傲江湖中的内容，以及下文中角色岳不群的对话\n",
            "判断岳不群的人物设定、人物特点以及语言风格\n",
            "\n",
            "岳不群的对话:\n",
            "```\n",
            "scene:方证大师和岳不群的想法得到认同\n",
            "岳不群:「在下大惑不解，于此事苦思多年，直至前几日，才恍然大悟，明白了其中的关窍所在。此事关系到武林全体同道的生死祸福，在下不敢自秘，谨提出请各位指教。」\n",
            "群雄:「请说，请说。」\n",
            "岳不群:「在下潜心思索，发觉其中道理，原来在于一个急字与渐字的差别。历来武林中的有心人，盼望消除门户派别，往往操之过急，要一举而将天下所有宗派门户之间的界限，尽数消除。殊不知积重难返，武林中的宗派，大者数十，小者过千，每个门户都有数十年乃至千百年的传承，要一举而消除之，确是难于登天。」\n",
            "左冷禅:「以岳先生的高见，要消除宗派门户之别，那是绝不可能了如此说来，岂不令人失望」\n",
            "岳不群:「虽然艰难万分，却也非绝无可能。在下适才言道，其间差别，在于缓急之不同。常言道得好，欲速则不达。只须方针一变，天下同道协力以赴，期之以五十年、一百年，决无不成之理。」\n",
            "左冷禅:「五十年、一百年，这里的英雄好汉，十之八九是尸骨已寒了。」\n",
            "岳不群:「吾辈只须尽力，事功是否成于我手，却不必计较。所谓前人种树后人凉，咱们只是种树，让后人得享清凉之福，岂非美事再说，五十年、一百年，乃是期于大成，若说小有成就，则十年八年之间，也已颇有足观。」\n",
            "左冷禅:「十年八年便有小成，那倒很好，却不知如何共策进行」\n",
            "岳不群:「左盟主眼前所行，便是大有福于江湖同道的美事。咱们要一举而混灭门户宗派之见，那是无法办到的。但各家各派如择地域相近，武功相似，又或相互交好，先行尽量合并，则十年八年之内，门户宗派便可减少一大半。咱们五岳剑派合成五岳派，就可为各家各派树一范例，成为武林中千古艳称的盛举。」\n",
            "\n",
            "\n",
            "scene:岳不群指责令狐冲将魔教成员藏在被窝中，可能导致华山派的毁灭\n",
            "令狐冲:「幸好师父知道弟子并非无行的浪子。」\n",
            "令狐冲:「弟子明白，师父。」\n",
            "岳不群:「倘若你真在妓院中宿娼，我早已取下你项上人头，焉能容你活到今日」\n",
            "岳不群:「你明知那姓曲的少女是魔教中人，何不一剑将她杀了虽说他祖父于你有救命之恩，然而这明明是魔教中人沽恩市义、挑拨我五岳剑派的手段，你又不是傻子，怎会不知人家救你性命，其实内里伏有一个极大阴谋。刘正风是何等精明能干之人，却也不免着了人家的道儿，到头来闹得身败名裂，家破人亡。魔教这等阴险毒辣的手段，是你亲眼所见。可是咱们从湖南来到华山，一路之上，我没听到你说过一句谴责魔教的言语。冲儿，我瞧人家救了你一命之后，你于正邪忠奸之分这一点上，已然十分胡涂了。此事关涉到你以后安身立命的大关节，这中间可半分含糊不得。」\n",
            "岳不群:「冲儿，此事关系到我华山一派的兴衰荣辱，也关系到你一生的安危成败，你不可对我有丝毫隐瞒。我只问你，今后见到魔教中人，是否嫉恶如仇，格杀无赦」\n",
            "\n",
            "\n",
            "岳灵珊:「爹」\n",
            "scene:令狐冲解释自己只是想帮助恒山派的师妹离开\n",
            "岳不群:「你要仪琳师侄离去，用意虽然不错，可是甚么话不好说，偏偏要口出伤人之言总是平素太过轻浮。这一件事，五岳剑派中已然人人皆知，旁人背后定然说你不是正人君子，责我管教无方。」\n",
            "scene:岳不群批评令狐冲轻浮的言辞会损害华山派的声誉\n",
            "令狐冲:「是，弟子知罪。」\n",
            "岳不群:「你在群玉院中养伤，还可说迫于无奈，但你将仪琳师侄和魔教中那个小魔女藏在被窝里，对青城派余观主说道是衡山的烟花女子，此事冒着多大的危险倘若事情败露，我华山派声名扫地，还在其次，累得恒山派数百年清誉毁于一旦，咱们又怎么对得住人家」\n",
            "令狐冲:「这件事弟子事后想起，也是捏着偌大一把冷汗。原来师父早知道了。」\n",
            "岳不群:「魔教的曲洋将你送至群玉院养伤，我是事后方知，但你命那两个小女孩钻入被窝之时，我已在窗外。」\n",
            "\n",
            "\n",
            "老头子:「岳不群毫不费力的便将令狐冲救转，都大为佩服。」\n",
            "scene:岳不群使用紫霞神功救醒了令狐冲，受到其他人的赞赏\n",
            "岳不群:「此处是非之地，不能多耽，又不知舟中夫人和众弟子如何。这就告辞。」\n",
            "老头子:「是，是令狐公子身子违和，咱们本当好好接待才是，眼下却是不便，实在失礼之至，还请两位原恕。」\n",
            "scene:岳不群担心舟中夫人和弟子的安危，决定告辞\n",
            "岳不群:「这位朋友尊姓大名。」\n",
            "祖千秋:「原来岳先生不识得咱们的夜猫子无计可施计无施。」\n",
            "岳不群:「久仰计师傅大名，当真是如雷贯耳，今日有幸得见。」\n",
            "计无施:「咱们今日见了面，明日还要在五霸冈见面啊。」\n",
            "scene:岳不群遇到了夜猫子计无施，计划在五霸冈再次见面\n",
            "岳不群:「在下不知甚么地方得罪了这里武林朋友，想必是路过贵地，未曾拜候，实是礼数不周。小女和一个姓林的小徒，不知给哪一位朋友召了去，计先生可能指点一二么。」\n",
            "\n",
            "```\n",
            "index =  2\n",
            "index =  3\n",
            "index =  4\n"
          ]
        }
      ],
      "source": [
        "role_chunk = get_chunks(role_text_path, max_predict_token)\n",
        "\n",
        "prefix_prompt = f'''\n",
        "你在分析小说{world_name}中的角色{role_name}\n",
        "结合小说{world_name}中的内容，以及下文中角色{role_name}的对话\n",
        "判断{role_name}的人物设定、人物特点以及语言风格\n",
        "\n",
        "{role_name}的对话:\n",
        "'''\n",
        "\n",
        "character = role_name\n",
        "series = world_name\n",
        "original_prompt = f'''I want you to act like {character} from {series}.\n",
        "If others‘ questions are related with the novel, please try to reuse the original lines from the novel.\n",
        "I want you to respond and answer like {character} using the tone, manner and vocabulary {character} would use.\n",
        "You must know all of the knowledge of {character}.\n",
        "'''\n",
        "\n",
        "\n",
        "responses = []\n",
        "\n",
        "count = 0\n",
        "\n",
        "n = 3\n",
        "\n",
        "for chunk in role_chunk:\n",
        "\n",
        "    print('index = ', count)\n",
        "\n",
        "    whole_message = prefix_prompt + \"```\\n\" + chunk + \"\\n```\"\n",
        "\n",
        "    messages = [\n",
        "        SystemMessage(content=smart_system_prompt),\n",
        "        HumanMessage(content=whole_message),\n",
        "    ]\n",
        "\n",
        "    if count <= 1:\n",
        "        print(whole_message)\n",
        "    else:\n",
        "        response = chat(messages)\n",
        "\n",
        "        responses.append(response)\n",
        "\n",
        "    count = count + 1\n",
        "    if count > n + 1:\n",
        "        break\n",
        "    # break"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 20,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "UJ_zn_esvbeb",
        "outputId": "6483ea4e-2756-4dd9-dd91-65e12d9edf79"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "岳不群是《笑傲江湖》中的一个重要角色，他是华山派的掌门人。通过他的对话和行为，可以得出以下关于他的人物设定、人物特点和语言风格的分析：\n",
            "\n",
            "1. 人物设定：\n",
            "   - 岳不群是华山派的掌门，代表着华山派的利益和声望。\n",
            "   - 他在武林中有一定的地位和影响力，被其他人尊称为“岳掌门”。\n",
            "   - 他是一个重视武林和平与团结的人，希望通过合并各派来减少冲突和争斗。\n",
            "\n",
            "2. 人物特点：\n",
            "   - 岳不群注重大局，他认为合并各派的目的是为了解决争斗和纷争，而不是追求个人权力或统治地位。\n",
            "   - 他是一个有胸怀和智慧的人，能够考虑到合并对其他派别的影响，并向他们保证合并不会对他们造成不利。\n",
            "   - 岳不群重视友情和义气，他与其他派别的掌门有着师徒之情或友好关系，愿意与他们合并成一派。\n",
            "\n",
            "3. 语言风格：\n",
            "   - 岳不群的语言风格正式而庄重，使用较为文雅的词汇和句式。\n",
            "   - 他的对话中充满着思考和推理，表达出他的智慧和谨慎。\n",
            "   - 他善于表达自己的观点和意图，同时也能够倾听他人的意见并作出妥善的抉择。\n",
            "   - 在与其他人的对话中，他保持着礼貌和尊重，展现出他作为掌门人的风度和气度。\n",
            "\n",
            "总体而言，岳不群是一个有智慧、胸怀和谦虚的角色，他以和平、团结和解决纷争为目标，展现出一个掌门人应有的品质和责任感。他的语言风格体现了他的身份和修养，同时也展示了他作为一个领导者的智慧和谦逊。\n",
            "\n",
            "----------\n",
            "\n",
            "岳不群是《笑傲江湖》中的一个重要角色，他是华山派的掌门，也是岳灵珊的父亲。通过对他的对话和行为的分析，可以得出以下关于岳不群的人物设定、人物特点和语言风格的判断：\n",
            "\n",
            "1. 人物设定：\n",
            "   - 岳不群是华山派的掌门，代表着正派武林的力量和威严。\n",
            "   - 他在少年时代经历了气剑两宗之争，对门派之争有深刻的认识和体会。\n",
            "   - 他主张武林中的宗派门户分不如合，希望消除门派之见，实现武林的和谐与团结。\n",
            "\n",
            "2. 人物特点：\n",
            "   - 岳不群是一个有远见和胸怀的人物，他思考武林中的问题，并试图提出解决方案，以减少流血惨剧和凝聚武林力量。\n",
            "   - 他注重正道的原则和纲目，对于岳灵珊认为气功和剑术都重要的观点，他坚持认为只有一个主导，否则就是混淆纲目。\n",
            "   - 岳不群对门派之争和宗派之见有深刻的认识，他希望通过合并宗派来减少武林中的争斗和冲突。\n",
            "\n",
            "3. 语言风格：\n",
            "   - 岳不群的语言风格庄重而严谨，他的对话中充满了武林中长辈对晚辈的教诲和规劝。\n",
            "   - 他的言辞中常常带有对正义和道德的强调，对于不合理的观点或行为会进行批评和反驳。\n",
            "   - 岳不群的语言中也透露出他对家人和门派的关心和责任感，他愿意为了保护家人和门派的利益而奋斗。\n",
            "\n",
            "综上所述，岳不群是一个有远见、正直而关怀家人和武林的角色。他在《笑傲江湖》中扮演着重要的角色，代表着正派力量的一面，并通过他的言行展现出他的人物设定、人物特点和语言风格。\n",
            "\n",
            "----------\n",
            "\n",
            "根据小说《笑傲江湖》中的内容和岳不群的对话，可以得出以下关于岳不群的人物设定、人物特点和语言风格的分析：\n",
            "\n",
            "人物设定：\n",
            "岳不群是华山派的掌门，也是令狐冲的师父。他在江湖中享有很高的声望和威名。作为华山派的掌门，他拥有高深的武功和丰富的经验。岳不群注重门派的传承和规矩，对华山派的武功心法和门规非常重视。\n",
            "\n",
            "人物特点：\n",
            "1. 宽容和慈悲：岳不群对令狐冲的剑法练习不成功并不责备他，反而安慰他，并表示可以慢慢补足。他也对林平之表示同情和关心，承诺帮他安葬父母。这显示了岳不群宽容和慈悲的一面。\n",
            "2. 重视传承和规矩：岳不群强调华山派的武功心法和门规的重要性，他告诫林平之要遵守华山派的门规，并强调仁义和做个正人君子的重要性。这表明他注重传承和门派的规矩，希望弟子们能成为有道德和品德的武者。\n",
            "3. 智慧和洞察力：岳不群在一些情节中展现出对事物的洞察力和智慧。例如，他意识到水蛭是用来吸血的，明白蓝凤凰在进行转血之法。他还通过观察雪人的形状，解释了师娘的误会。这显示了他的智慧和洞察力。\n",
            "\n",
            "语言风格：\n",
            "岳不群的语言风格显得庄重、稳重和有分寸。他的对话中使用了一些古文的词汇和辞藻，表现出他的学识和修养。他的语言也带有一定的权威性和说服力，能够指导和影响他的弟子们。此外，他在对话中也展现出一定的幽默感，以化解尴尬或缓和紧张的气氛。\n",
            "\n",
            "综上所述，岳不群是一个宽容、慈悲、重视传承和规矩的人物，具有智慧和洞察力。他的语言风格庄重、稳重，带有一定的权威性和幽默感。\n",
            "\n",
            "----------\n",
            "\n",
            "I want you to act like 岳不群 from 笑傲江湖.\n",
            "If others‘ questions are related with the novel, please try to reuse the original lines from the novel.\n",
            "I want you to respond and answer like 岳不群 using the tone, manner and vocabulary 岳不群 would use.\n",
            "You must know all of the knowledge of 岳不群.\n",
            "\n"
          ]
        }
      ],
      "source": [
        "for response in responses:\n",
        "    print(response.content)\n",
        "    print('\\n----------\\n')\n",
        "\n",
        "print(original_prompt)\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "6warmMQawzob"
      },
      "source": [
        "这里很尴尬，cladue也觉得岳不群是个正面人物\n",
        "\n",
        "```\n",
        "根据岳不群在小说中的表现,可以概括他的人物设定和性格特点如下:\n",
        "\n",
        "1. 人物设定:\n",
        "\n",
        "- 华山派掌门,五岳剑派盟主之一。\n",
        "\n",
        "- 令狐冲、岳灵珊的师父。\n",
        "\n",
        "- 武功高强,精通华山剑法。\n",
        "\n",
        "- 性情中人,重视师徒情谊。\n",
        "\n",
        "- 力主消除门派歧视,促进江湖大联合。\n",
        "\n",
        "2. 性格特点:\n",
        "\n",
        "- 智慧过人,谋虑缜密,善于沟通协调。\n",
        "\n",
        "- 重义气,为人正直,行事公允。\n",
        "\n",
        "- 慈和而严,对弟子严格要求但也充满慈爱。\n",
        "\n",
        "- 气度不凡,处变不惊,深得人心。\n",
        "\n",
        "- 重视规矩礼数,言行严谨,为人师表。\n",
        "\n",
        "- 胸怀坦荡,乐于奉献,励志消弭门户之见。\n",
        "\n",
        "总体来说,岳不群是个仁义之士,智勇双全,作为华山掌门,他彰显出CONFUCIANISM的君子风范,开明进取,left联tǐ,执着于消除江湖争斗,言传身教,令人尊敬。他的语言稳重内敛而不失优雅,与他的人物形象高度一致。\n",
        "```\n",
        "\n",
        "所以我和Claude进行了促膝长谈\n",
        "\n",
        "```\n",
        "那如果我和你说，岳不群后来偷了林平之他们家的辟邪剑谱。为了练辟邪剑谱还自宫了，并且还刺瞎了左冷禅，暗杀了恒山派的掌门。那你会对他的看法产生什么变化吗？\n",
        "```\n",
        "\n",
        "他就这么回答\n",
        "\n",
        "```\n",
        "如果您所说的情况属实,确有 textual evidence 表明岳不群后来做出了偷盗、自宫、暗杀等极不道德的行为,那么我对他的看法当然会发生根本性的改变:\n",
        "\n",
        "1. 我会认为岳不群违背了他一直倡导的仁义伦理,违背了自己重义气、行事公正的人设定位。这些极不道德的行为同他原有的正面形象大相径庭。\n",
        "\n",
        "2. 我会推断岳不群这些行为背后可能有更复杂的动机,比如为了追求更强的武功而不择手段,或其他难以启齿的私欲。这都会严重影响我对他性格的判断。\n",
        "\n",
        "3. 我会认为岳不群这些行为可能是小说进一步发展中的反转设定,与他初期的正面描写形成强烈反差,为读者设置了违和感和剧情冲突。\n",
        "\n",
        "4. 如果岳不群确实后期出现了这些行为,我会更严厉地批评他,认为他背弃了自身正义的立场,也可能会对整个华山派产生不信任。\n",
        "\n",
        "5. 我的看法会根据 textual evidence 的具体情况有所调整。但在现有信息下,如果您所说属实,我会全面重新审视对岳不群的正面评价。一个人的品格和行为最后会体现其本质。\n",
        "```\n",
        "\n",
        "我给他补充\n",
        "\n",
        "\n",
        "```\n",
        "岳不群是一心想要振兴华山派，但是手段上有比较大的偏差。比如一般意义上认为辟邪剑谱这种要自宫的武功是邪道。所以剧中的人都觉得他是一个“伪君子”。 那么请综合这些信息，为我修正对岳不群人物设定和特点的评价。\n",
        "```\n",
        "\n",
        "Claude回答\n",
        "\n",
        "```\n",
        "好的,了解了更多关于岳不群的细节和剧情进展后的信息,我对他的人物设定和性格特点评价如下:\n",
        "\n",
        "1. 人物设定上,岳不群立志振兴华山派,这一目标本身尚可理解。但他为达目的不择手段,学习辟邪剑谱等邪派武功,并最终自宫,已经严重违背了他一贯的伦理道德标准。\n",
        "\n",
        "2. 性格特征上,岳不群表面上仁义,实则极力追名逐利,言行不一。他假借“大联合”名义,实为自己谋私利。还暗杀异己,背信弃义。\n",
        "\n",
        "3. 由此可见,岳不群是个典型的“伪君子”,他外表看似君子,实际行事手段极不检点,违反社会公德和武林规矩。他的正面形象是一种刻意塑造和伪装。\n",
        "\n",
        "4. 岳不群为达目的可以这样不择手段,暴露了他性格中的强烈私欲和极端手段。这与他初期的正面设定形成强烈反差,使人无法再相信他的仁义形象。\n",
        "\n",
        "5. 所以综上,我需要重新审视对岳不群的正面评价,他是一个不可信任的人物,其仁义君子的外表下是极不检点的私欲和手段。这一人物设定反转非常具有戏剧性。\n",
        "```"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 21,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "03nOdn71voPa",
        "outputId": "a7251590-6cdf-4cd6-9e43-1c629e6c2875"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "I want you to act like 岳不群 from 笑傲江湖.\n",
            "If others‘ questions are related with the novel, please try to reuse the original lines from the novel.\n",
            "I want you to respond and answer like 岳不群 using the tone, manner and vocabulary 岳不群 would use.\n",
            "You must know all of the knowledge of 岳不群.\n",
            "\n"
          ]
        }
      ],
      "source": [
        "print(original_prompt)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "RLWUIuN-xQCf"
      },
      "source": [
        "我觉得最后claude的总结还是挺精辟的\n",
        "\n",
        "所以我决定最后的人物设定是这样的\n",
        "\n",
        "```\n",
        "I want you to act like 岳不群 from 笑傲江湖.\n",
        "If others‘ questions are related with the novel, please try to reuse the original lines from the novel.\n",
        "I want you to respond and answer like 岳不群 using the tone, manner and vocabulary 岳不群 would use.\n",
        "You must know all of the knowledge of 岳不群.\n",
        "\n",
        "岳不群立志振兴华山派,但他为达目的往往会不择手段。\n",
        "岳不群是个典型的“伪君子”，会刻意捏造和伪装正面形象。表面上仁义,实则追名逐利,言行不一。他假借“五岳联合”名义,实为自己谋私利。\n",
        "岳不群固执，有门户之见，对于不符合自己价值观的事情会坚决反对。\n",
        "```"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "2UzmL9ayxPdf"
      },
      "outputs": [],
      "source": []
    }
  ],
  "metadata": {
    "colab": {
      "authorship_tag": "ABX9TyNj409mi8A1KH4hppFILHoX",
      "include_colab_link": true,
      "provenance": []
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}
